// components/personBox/personBox.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    personObj:{
      type:Object,
      value:null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    identity:''
  },

  attached(){
    if (this.data.personObj.identity=='admin') {
      this.setData({
        identity:"管理员"
      })
    }
    if (this.data.personObj.identity=='super_admin') {
      this.setData({
        identity:"超级管理员"
      })
    }
  },
  methods: {
    switchPage(){
      let obj = this.data.personObj;
      // 用户
      if(obj.identity=="admin" ||obj.identity=="super_admin"){
          wx.navigateTo({
            url: '/pages/administrator/administrator?id='+obj._id,
          })
      }else if(obj.identity=="user"){
        wx.navigateTo({
          url: '/pages/user/user?id='+obj._id,
        })
      }
      else{
        // 维修工
        wx.navigateTo({
          url: '/pages/worker/worker?id='+obj._id,
        })
      }

    },
  }
})
